﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BonjourHotel.Core.Menu;

namespace BonjourHotel.Application.Controls.Hotels
{
    public partial class HotelMainMenu : BaseBHMenu
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                base.GetLocalization("Hotel");
                btnCreateHotel.Text = CreateText;
                btnUpdateHotel.Text = UpdateText;
                btnRemoveHotel.Text = RemoveText;
                btnFindHotel.Text = FindText;
                btnSortHotel.Text = SortText;

                if (Mode == MenuMode.Create || Mode == MenuMode.Update)
                {
                    btnCreateHotel.Enabled = false;
                    btnUpdateHotel.Enabled = false;
                    btnRemoveHotel.Enabled = false;
                    btnFindHotel.Enabled = false;
                    btnSortHotel.Enabled = false;
                }
            }
        }

        public event EventHandler Create;
        public event EventHandler Update;
        public event EventHandler Remove;
        public event EventHandler Sort;
        public event EventHandler Find;


        protected void btnHotelMainMenu_Click(object sender, EventArgs e)
        {
            IButtonControl btn = (IButtonControl)sender;

            switch (btn.CommandName)
            {
                case "create":
                    if (Create != null) Create(this, null);
                    break;
                case "update":
                    if (Update != null) Update(this, null);
                    break;
                case "remove":
                    if (Remove != null) Remove(this, null);
                    break;
                case "sort":
                    if (Sort != null) Sort(this, null);
                    break;
                case "find":
                    if (Find != null) Find(this, null);
                    break;
            }
        }
    }
}